
const stu = {
    name: '瑞斯邦' ,
    age: 22 ,
    hometown: '绵阳'
}

const template = '大家好，我是${name}，我来自${hometown}，今年${age}岁';

const regexp = /\$\{\w+\}/; 

console.log( regexp.test( template ) );

let result = regexp.exec( template );
console.log( result );
let metched = result[0] ;
// String.prototype.replace( regexp|substr , replacement|function )
let str = template.replace( metched , stu.name );
console.log( str );

result = regexp.exec( str );
console.log( result );
metched = result[0] ;
str = str.replace( metched , stu.hometown );
console.log( str );

result = regexp.exec( str );
console.log( result );
metched = result[0] ;
str = str.replace( metched , stu.age );
console.log( str );